#Dockerfile
  
FROM ubuntu:16.04  
MAINTAINER huchen  

ENV ENGINE_ENV_VERSION 1.0.5_luohd

ENV TIME_ZONE Asia/Shanghai
ENV SSH_PASSWORD introcks

# install ssh service and set time zone
RUN apt-get update && \
    apt-get install -y openssh-server && \
    echo "root:${SSH_PASSWORD}" | chpasswd && \
    mkdir -p /var/run/sshd && \
    apt-get install -y tzdata && \
    echo "${TIME_ZONE}" > /etc/timezone && \
    rm -rf /etc/localtime && \
    ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime && \
    echo "export LANG=C.UTF-8" > /etc/profile && \
    apt-get clean
ADD sshd_config /etc/ssh/

# install IFaceEngine compile and run dependent libraries
COPY sources.list /etc/apt/sources.list
RUN apt-get update && \
    apt-get install -y libevent-2.0-5 && \
    apt-get install -y libpng12-0 && \
    apt-get install -y libldap2-dev && \
    apt-get install -y libusb-1.0-0 && \
    apt-get install -y libfreetype6 && \
    apt-get install -y libjson-c2 && \
    apt-get install -y libdbus-1-3 && \
    apt-get install -y libslang2 && \
    apt-get install -y libglib2.0-0 && \
    apt-get install -y libdrm2 && \
    apt-get install -y libltdl7 && \
    apt-get install -y libgtk2.0-dev && \
    apt-get install -y libglew-dev && \
    apt-get install -y gfortran && \
    apt-get install -y libjasper-dev && \
    apt-get install -y libraw1394-11 && \
    apt-get clean

# add net protocol file for current os image
ADD protocols /etc/

# nvidia-docker 1.0
LABEL com.nvidia.volumes.needed="nvidia_driver"
#LABEL com.nvidia.cuda.version="${CUDA_VERSION}"

RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
    echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

ENV PATH /usr/local/nvidia/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES video,compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=9.1"

# install common tools
RUN apt-get install -y gcc-4.8 && \
    apt-get install -y g++-4.8 && \
    apt-get install -y net-tools && \
    apt-get install -y bc && \
    apt-get install -y gdb && \
    apt-get install -y vim && \
    apt-get install -y curl && \
    apt-get install -y telnet && \
    apt-get install -y make && \
    apt-get install -y git && \
    apt-get install -y python2.7 && \
    apt-get install -y unzip && \
    apt-get install -y inetutils-ping && \
    apt-get install -y cmake && \
    apt-get install -y htop && \
    apt-get install -y ncdu && \
    apt-get install -y lrzsz && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 && \
    apt-get clean

ADD thrift /usr/bin/ 

CMD ["/usr/sbin/sshd", "-D"]

#End

